const HOST = `https://wh.qingshanyuwo.cn/api`
const host = 'https://wh.qingshanyuwo.cn'

import Vue from 'vue'
	
function setFetch(token=sessionStorage.getItem('token')||'') {
	Vue.prototype.$fetch = (type, url, data={}) => {	
		let option = {
			header: {
				'Access-Token': token
			},
			url,
			method: type,
			data
		}
		
		let promise = new Promise(function(resolve, reject) {
			uni.request(option)
			.then(res => {
				resolve(res[1])
			})
			.catch(err => {
				reject(err)
			})
		})
		
		return promise
	}
}

export {
	host, HOST, setFetch
}